package Thread;

public class SynApiDemo {
    public static void main(String[] args) {
        StringBuilder sb=new StringBuilder();
//        StringBuffer sb=new StringBuffer();
        Thread t1=new Thread(){
            public void run() {
                for (int i = 0; i < 1000; i++) {
                    sb.append("abc");
                }
                System.out.println("t1线程执行完毕");
            }
        };
        Thread t2=new Thread(){
            public void run() {
                for (int i = 0; i < 1000; i++) {
                    sb.append("def");
                }
                System.out.println("t2线程执行完毕");
            }
        };
        t1.start();
        t2.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(sb.length());


    }
}
